home *** CD-ROM | disk | FTP | other *** search
- /* include file to provide graphics */
- /* functions supported:
- tekopen();
- vectoa(x,y) int x,y;
- posita(x,y) int x,y;
- dperas();
- gfxfont(number,size) int number,size;
- gfxtext(s,a) char s[]; float a;
- textlen(s) char s[];
- textheight()
- getxy(x,y) int *x,*y;
- gfxflush();
- textparam(sx,sy,tx,ty,w,namw) int sx,sy,tx,ty,w; char *name;
- rmtek();
- setcolour(n) int n;
- special_gfx(s) char *s; do special operations like PostScript output
- */
- #ifdef AMIGA
- #define TEKPIPENAME0 "PIPE:tek0"
- #define TEKPIPENAME1 "PIPE:tek1"
- #define TEKPIPENAME2 "PIPE:tek2"
- #define TEKPIPENAME3 "PIPE:tek3"
- #define TMPGCURSOR "t:gcursor"
- #define ASHBDRY "t:ashbdry"
- #endif
- #ifdef UNIX
- #define TEKPIPENAME0 "/dev/tek.pipe"
- #define TEKPIPENAME1 "/dev/tek.pipe1"
- #define TEKPIPENAME2 "/dev/tek.pipe2"
- #define TEKPIPENAME3 "/dev/tek.pipe3"
- #define ASHBDRY "/tmp/ashbdry"
- #endif
-
- #define _TEKXMAX 4096
- #define _TEKYMAX 3120
-
- #ifndef _SPECHDR
- #include <auxcfg.h>
- #include <spec.h>
- #endif
-
-
- int _tek4014,
- _tek4014_flg = 0,
- _gfxbufp = 0,
- _gfxfontnr = 1,
- _gfxfontsz = 1;
- int _lasttextheight = 0;
-
- char *_tekname, *_tekoname;
-
- unsigned char _gfxbuf[8192];
-
-
- tekopen()
- {
- char c,s[80],z[80],str[80],name[80];
- char *display;
- int i,n,m;
-
- _tekname = (char *) malloc(128);
- _tekoname = (char *) malloc(128);
-
- strcpy(name,"OUTPUT");
- if(_tekpipe == 0) strcpy(name,"ANALYSIS");
- if(_tekpipe == 1) strcpy(name,"ON_LINE");
- if(_tekpipe == 2) strcpy(name,"EXTRA");
- strcpy(s,"gfx");
- c=_tekpipe+48;
- z[0]=c; z[1]=0;
- strcat(s,z);
- display = (char *)getenv("DISPLAY"); /* used to identify ASCII terminals */
- _tek4014=auxopen(s); /* _tekpipe is defined in spec.h */
-
- if(_tek4014 <= 0) {
- sprintf(str,"(xterm -t -T %s %c400x400+0+0 -e $LISEPRG/tekdaemon -p %d )&",name,'%',_tekpipe);
- if(display != NULL) {
- system(str); sleep(6);
- } else {
- system("$LISEPRG/tekdaemon&");
- }
- n = 0;
- while(n < 30) {
- sleep(1);
- _tek4014=auxopen(s); /* _tekpipe is defined in spec.h */
- if(_tek4014 > 0) break;
- }
- if(_tek4014 <= 0) {
- sprintf(str,"(xterm -t -T %s %c400x400+0+0 -e tekdaemon -p %d )&",name,'%',_tekpipe);
- if(display != NULL) {
- system(str); sleep(6);
- } else {
- system("tekdaemon&");
- }
- n = 0;
- while(n < 30) {
- sleep(1);
- _tek4014=auxopen(s); /* _tekpipe is defined in spec.h */
- if(_tek4014 > 0) break;
- }
- }
- }
- if(_tek4014 <= 0) {
- fprintf(stderr,"failed to open graphic pipe\n");
- }
-
- strcpy(_tekname,auxparams[0]);
- strcpy(_tekoname,_tekname); strcat(_tekoname,"o");
-
- return(_tek4014);
- }
-
- gfxflush()
- {
- int n;
-
- write(_tek4014,_gfxbuf,_gfxbufp);
- _gfxbufp=0;
- }
-
- gfxbufin(n)
- int n;
- {
- _gfxbuf[_gfxbufp++]=n;
- if(_gfxbufp>8190) gfxflush();
- }
-
- cvtxy(xx,yy)
- int xx,yy;
- {
- int n,m,i,xh,yh,x,y;
- int x4, y4, xl, yl;
- char ch,cl;
-
- switch(_win_flg){
- case 0:
- x=xx ; y=yy; break;
- case 1:
- x=xx ; y=yy/2; break;
- case 2:
- x=xx ; y=yy/2 + (_TEKYMAX/2); break;
- case 3:
- x=xx/2 ; y=yy/2 + (_TEKYMAX/2); break;
- case 4:
- x=xx/2 + (_TEKXMAX/2) ; y=yy/2 + (_TEKYMAX/2); break;
- case 5:
- x=xx/2 ; y=yy/2; break;
- case 6:
- x=xx/2 + (_TEKXMAX/2) ; y=yy/2; break;
- }
- x4 = x >> 2; y4 = y >> 2;
- yh = y4 >> 5; yl = y4 & 31;
- xh = x4 >> 5; xl = x4 & 31;
- i = (x & 3) + 4 * (y & 3);
- gfxbufin(yh | 32);
- gfxbufin(i | 96);
- gfxbufin(yl | 96);
- gfxbufin(xh | 32);
- gfxbufin(xl | 64);
- }
-
- posita(x,y)
- int x,y;
- {
- int n,m;
-
- gfxbufin(0x1d);
- if(x > _TEKXMAX) x = _TEKXMAX;
- if(x < 0) x = 0;
- if(y > _TEKYMAX) y = _TEKYMAX;
- if(y < 0) y = 0;
- cvtxy(x,y);
- }
-
- vectoa(x,y)
- int x,y;
- {
- int n,m;
-
- if(x > _TEKXMAX) x = _TEKXMAX;
- if(x < 0) x = 0;
- if(y > _TEKYMAX) y = _TEKYMAX;
- if(y < 0) y = 0;
- cvtxy(x,y);
- }
-
- dperas()
- {
- gfxbufin(0x1b);
- gfxbufin(0x0c);
- gfxflush();
- }
-
-
- getxy(x,y)
- int *x,*y;
- {
- int n,i,fp;
- char s[8];
-
- n=0;
- gfxbufin(0x1b);
- gfxbufin(0x1a);
- gfxflush();
- fp=-1;
- while(fp<0) {
- sleep(1);
- fp=open(_tekoname,2);
- }
- i=read(fp,s,5);
- close(fp);
- *x = 4 * ((s[0] & 31)*32+(s[1] & 31));
- *y = 4 * ((s[2] & 31)*32+(s[3] & 31));
- }
-
-
- textlen(str)
- char *str;
- {
- int n,i,fp;
- char s[12];
-
- gfxbufin(0x1b);
- gfxbufin(0x1c);
- n = 0; while(str[n] != 0) gfxbufin(str[n++]);
- gfxbufin(0);
- gfxflush();
- fp=-1;
- while(fp<0) {
- fp=open(_tekoname,2);
- }
- i=read(fp,s,10);
- close(fp);
- sscanf(s,"%d\n",&i);
- return(i);
- }
-
- textheight()
- {
- int i,n,fp;
- char s[12];
-
- if(_lasttextheight != 0) return(_lasttextheight);
- gfxbufin(0x1b);
- gfxbufin(0x1e);
- gfxflush();
- fp=-1;
- while(fp<0) {
- fp=open(_tekoname,2);
- }
- i=read(fp,s,10);
- close(fp);
- sscanf(s,"%d\n",&_lasttextheight);
- return(_lasttextheight);
- }
-
- gfxtext(s,a)
- char s[];
- float a;
- {
- int n;
- char z[256];
-
- gfxflush();
- z[0]=0x1b;
- z[1]=0;
- if(_win_flg==0) {
- strcat(z,"9"); /* normal text size */
- } else {
- strcat(z,";"); /* small text size */
- }
- strcat(z,s);
- gfxbufin(0x1f);
- for(n=0;n<strlen(z);n++) gfxbufin(z[n]);
- gfxflush();
- }
-
-
- setcolour(n)
- int n;
- {
- ;
- }
-
- rmtek()
- {
- dperas();
- gfxbufin(0x1b);
- gfxbufin(0x40);
- gfxflush();
- }
-
-
- textparam(sx,sy,tx,ty,w,name)
- int sx,sy,tx,ty,w;
- char name[];
- {
- int i,n;
- char c,s[80];
-
- gfxflush();
- sprintf(s,"0 %d %d %d %d %d %s",sx,sy,tx,ty,w,name); /* 0 signal textparam */
- gfxbufin(0x1b) ; /* ESC */
- gfxbufin(0x1b) ; /* second escape read special functions */
- i=0; c=1;
- while(c!=0) { /* special sequence is finished when 0 is reached */
- c=s[i++];
- gfxbufin(c);
- }
- gfxflush();
- }
-
- hco(str)
- char str[];
- {
- int i,n;
- char c,s[80];
-
- gfxflush();
- sprintf(s,"1 %s",str); /* 1 signal hardcopy */
- gfxbufin(0x1b) ; /* ESC */
- gfxbufin(0x1b) ; /* second escape read special functions */
- i=0; c=1;
- while(c!=0) { /* special sequence is finished when 0 is reached */
- c=s[i++];
- gfxbufin(c);
- }
- gfxflush();
- }
-
-
-
-
- gfxfont(number,size)
- int number,size;
- {
- _gfxfontnr=number;
- _gfxfontsz=size;
- }
-
- special_gfx(s)
- char *s;
- {
- int i,n;
- char c;
-
- gfxflush();
- gfxbufin(0x1b) ; /* ESC */
- gfxbufin(0x1b) ; /* second escape read special functions */
- i=0; c=1;
- while(c!=0) { /* special sequence is finished when 0 is reached */
- c=s[i++];
- gfxbufin(c);
- }
- gfxflush();
- }
-